import { createRouter, createWebHistory } from "vue-router";
import index from '@/components/layout'
import home from '@/views/home'
import readme from '@/components/readme'
import form from '@/views/form'
import echarts from '@/views/echarts'
import picCut from '@/views/pic-cut'
import tuopu from '@/views/tuopu'
import cesium from '@/views/cesium'
import map from '@/views/map'
import drag from '@/views/drag'
import clickMenu from '@/views/click-menu'
import echarts3d from '@/views/echarts3d'
import login from '@/components/login'
import notFound from '@/components/404'
const routes = [
  {
    path: '/index',
    name: 'index',
    component: index,
    children: [
      {
        path: '/home',
        name: 'home',
        component: home
      },
      {
        path: '/readme',
        name: 'readme',
        component: readme
      },
      {
        path: '/functions/table',
        name: 'functions-table',
        component: require('@/views/table')
      },
      {
        path: '/functions/form',
        name: 'functions-form',
        component: form
      },
      {
        path: '/functions/echarts',
        name: 'functions-echarts',
        component: echarts
      },
      {
        path: '/functions/picCut',
        name: 'functions-pic-cut',
        component: picCut
      },
      {
        path: '/functions/tuopu',
        name: 'functions-tuopu',
        component: tuopu
      },
      {
        path: '/functions/cesium',
        name: 'functions-cesium',
        component: cesium
      },
      {
        path: '/functions/map',
        name: 'functions-map',
        component: map
      },
      {
        path: '/functions/drag',
        name: 'functions-drag',
        component: drag
      },
      {
        path: '/functions/clickMenu',
        name: 'functions-click-menu',
        component: clickMenu
      },
      {
        path: '/functions/echarts3d',
        name: 'functions-echarts3d',
        component: echarts3d
      },
      {
        path: '',
        name: 'redirect',
        redirect: '/home'
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: login
  },
  {
    path: '/',
    redirect: '/index'
  },
  {
    path: '/:catchAll(.*)',
    name: '404',
    component: notFound
  }
]

const router = createRouter({
  history: createWebHistory(
    window.__POWERED_BY_QIANKUN__ ? "/vue" : "/"
  ),
  routes
})

export default router